'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    /*
      Add altering commands here.
      Return a promise to correctly handle asynchronicity.

      Example:
      return queryInterface.createTable('users', { id: Sequelize.INTEGER });
    */
    const { INTEGER, STRING, DATE, TEXT, NOW } = Sequelize;
    await queryInterface.createTable('l_page', {
      page_id: {
        type: INTEGER,
        primaryKey: true,
        autoIncrement: true,
        unique: true,
      },
      page_title: {
        type: STRING,
        defaultValue: '',
      },
      description: {
        type: STRING,
        defaultValue: '',
      },
      keyword: {
        type: STRING,
        defaultValue: '',
      },
      content: {
        type: TEXT,
        defaultValue: '',
      },
      cat_id: {
        type: INTEGER,
        defaultValue: 0,
        allowNull: false,
      },
      created_at: { type: DATE, defaultValue: NOW },
      update_at: { type: DATE, defaultValue: NOW },
    });
  },

  down: async (queryInterface, Sequelize) => {
    /*
      Add reverting commands here.
      Return a promise to correctly handle asynchronicity.

      Example:
      return queryInterface.dropTable('users');
    */
    await queryInterface.dropTable('l_page');
  },
};
